package org.jgs1904.quickstart.handler;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: 默苍璃
 * @date: 2025-06-0518:37
 */
public class MyForwardAuthenticationFailureHandler implements AuthenticationFailureHandler {

    private String url;

    public MyForwardAuthenticationFailureHandler(String url) {
        this.url = url;
    }

    @Override
    public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
        response.sendRedirect(url);
    }

}